package lg.minecraft.plugin.pokemonmenu.display;

import com.cobblemon.mod.common.pokemon.Pokemon;
import lg.minecraft.plugin.pokemonmenu.LGPokemonMenu;
import lg.minecraft.plugin.pokemonmenu.manager.DisplayPokemonManger;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;

/**
 * 宝可梦展示处理器，统一处理展示逻辑
 */
public class PokemonDisplayHandler {

    /**
     * 快捷方法：展示 PC 中的宝可梦
     */
    public static void showPCPokemon(Pokemon[] pokemonArray, String playerName) {
        long time = DisplayPokemonManger.INSTANCE.storePokemonWithTimestamp(pokemonArray);
        TextComponent component = LGPokemonMenu.getMessage().getShowPc(playerName, time);
        Bukkit.getOnlinePlayers().forEach(target -> target.spigot().sendMessage(component));
    }

    /**
     * 快捷方法：展示队伍中的宝可梦
     */
    public static void showPartyPokemon(Pokemon[] pokemonArray, String playerName) {
        long time = DisplayPokemonManger.INSTANCE.storePokemonWithTimestamp(pokemonArray);
        TextComponent component = LGPokemonMenu.getMessage().getShowParty(playerName, time);
        Bukkit.getOnlinePlayers().forEach(target -> target.spigot().sendMessage(component));
    }

    /**
     * 快捷方法：展示单个宝可梦
     */
    public static void showSinglePokemon(Pokemon pokemon, String playerName) {
        long time = DisplayPokemonManger.INSTANCE.storePokemonWithTimestamp(new Pokemon[]{pokemon});
        TextComponent component = LGPokemonMenu.getMessage().getShowPokemon(playerName, time, pokemon);
        Bukkit.getOnlinePlayers().forEach(target -> target.spigot().sendMessage(component));
    }

}
